#!/usr/bin/python
# pylint: disable-msg = W0142
'''
Created by Colin Gillespie <c.gillespie@ncl.ac.uk>
$LastChangedDate: 2008-03-13 19:50:58 +0000 (Thu, 13 Mar 2008) $

Caches functions.

'''

__revision__ = '$Rev: 73 $'


def memoize(fn):
    '''
        Used as a decorator to cache values
    '''
    memo = {}
    def memoizer(*param_tuple):
        '''
            Stores functions calls
        '''
        try:
            return memo[param_tuple]
        except KeyError:
            memo[param_tuple] = result = fn(*param_tuple)
            return result
    return memoizer

    

